﻿@using CoralNode.Core.Entity.Enums
@using CoralNode.MvcClient.Helper
@using Coralcode.Base.Entity
@using Coralcode.Base.Utils
@model CoralNode.Core.Entity.SearchQuerys.Site.SiteSearchQuery

@{
    ViewBag.Title = "ListNode";
    ViewBag.PageModule = "seo";
    ViewData["Module"] = "statistic";
}
@Html.IncludePage("CoralAdmin/Statistic", "_Left")
<!--content-->
<div id="pbody">
    <div class="extra">
        <div class="pbody_top">
            <span class="ico ico_setting_system"></span><span class="t t_c">站点SEO管理</span>
        </div>
        <div id="main">
            <div class="content_tab extra_normal">
                <div class="tablist extra_normal">
                    <a href="/m/seo/ListNodeSeo">内容SEO</a>
                    <a href="/m/seo/ListMenuSeo">菜单SEO</a>
                    <a class="current" href="/m/seo/ListSiteSeo">站点SEO</a>
                </div>
            </div>
            <div class="">
                <div class="tablelist_style1" data-js="tabellist_style1">
                    <div class="funsearch p_1 pl_2 pr_2 extra_normal">
                        <div class="f_r">
                            <form method="POST" action="/m/seo/ListSiteSeo">
                                <span class="t_des f_l pt_0-5">站点名称：</span>
                                <label class="search f_l">
                                    @Html.TextBoxFor(m => m.Name, new { @class = "text w_18", @msg = "请输入关键字" })
                                    @Html.AntiForgeryToken()
                                    <input type="submit" value="" class="submit" /></label>
                            </form>
                        </div>
                    </div>
                    <table class="tablelist_style2" cellpadding="0" cellspacing="0">
                        <thead class="exclude">
                            <tr>
                                <th width="100">站点logo</th>
                                <th width="500">概览</th>
                                <th>主题</th>
                                <th>状态</th>
                                <th width="140">操作</th>
                            </tr>
                        </thead>
                        @foreach (var item in ViewBag.SiteList.Items) {
                            <tr>
                                <td class="list_img">
                                    @if (!string.IsNullOrEmpty(@item.Logo)) {
                                        <img src="@item.Logo" alt="@item.Name"/>
                                    } else {
                                        <img src="/Themes/CoralAdmin/_misc/images/defaultLogo.jpg" alt="@item.Name"/>
                                    }
                                </td>
                                <td>
                                    <div class="des">
                                        <a  href="/m/seo/editSiteSeo?siteId=@item.Id" class="js_dialog_seo">@item.Name<span>[@item.LangCode]</span></a>
                                        <div>@item.Description</div>
                                    </div>
                                </td>
                                <td>@item.ThemeCode</td>
                                <td>@EnumUtil.GetEnumDescription(SiteEnums.SiteStatus, item.Status)</td>
                                <td width="50" class="opt">
                                    <div class="fun">
                                        <a href="/m/seo/editSiteSeo?siteId=@item.Id" class="js_dialog_seo">SEO设置</a>
                                    </div>
                                </td>
                            </tr>
                        }
                    </table>
                </div>
            </div>
        </div>
        <div id="pager">
            <div class="info_pg">共@(ViewBag.SiteList.TotalItems)条</div>
            <div class="list_pg">
                <a href="/m/node/listSite?@ViewBag.queryString&p=1" class="first">首页</a>
                @if (@ViewBag.SiteList.HasPreviousPage && @ViewBag.SiteList.TotalItems > 0) {
                    <a href="/m/node/listSite?@ViewBag.queryString&p=@ViewBag.SiteList.PreviousPageIndex" class="prev">
                        上一页</a>
                } else {
                    <a class="prev none">上一页</a>
                }
                @foreach (var i in @ViewBag.SiteList.PageArray) {
                    if (@i == @ViewBag.SiteList.CurrentPageIndex) {
                        <a class="current">@i</a>
                    } else if (@i == 0) {
                        <a class="more">…</a>
                    } else {
                        <a href="/m/node/listSite?@ViewBag.queryString&p=@i" href="#">@i</a>
                    }
                }
                @if (@ViewBag.SiteList.HasNextPage && @ViewBag.SiteList.TotalItems > 0) {
                    <a class="next" href="/m/node/listSite?@ViewBag.queryString&p=@ViewBag.SiteList.NextPageIndex">
                        下一页</a>
                } else {
                    <a class="next none">下一页</a>
                }
                <a class="last" href="/m/node/listSite?@ViewBag.queryString&p=@ViewBag.SiteList.TotalPages">
                    尾页</a>
                <!-- <span class="msg">跳转</span>
                    <input class="text" type="text" value="">
                    <span class="msg">页</span>-->
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        $(".js_dialog_seo").click(function (e) {
            e.preventDefault();
            var dialog = $.dialog({
                title: "设置SEO信息",
                content: '<img src="/Themes/CoralAdmin/_misc/images/loading.gif" style="display:block; margin:30px auto;" />',
                show: true,
                cancel: true,
                lock: true,
                ok: okfun,
                zIndex: 999
            });
            dialog.getJQuery().find(".d-state-highlight").css("margin-left", "140px");
            function okfun() {
                var $form = dialog.getJQuery().find("form");
                $.post($form.attr("action"), $form.serialize(), function (result) {
                    if (result.Type == 5) {
                        $.alert(result.Msg);
                        setTimeout(function () {
                            dialog.close();
                        }, 1000);
                    }
                });
            }
            var $this = $(this);
            dialog.visible();
            $.get($this.attr("href"), function (data) {
                dialog.content(data);
            });
        });
    })
</script>
